(function ($, im, doc) {
	//显示聊天信息页
	$.plusReady(function () {
		var transDoc = document.getElementById("transfer_accounts");
		//console.log(im.roomType); 
		if(im.roomType == 2){
			transDoc.parentNode.remove();
		}
		//点击转账 
		transDoc && transDoc.addEventListener('tap', function () {
			//if (im.roomType == 1) {
				var postUrl = apiurl + "wallet/getWallets";
				var postdata = {
					from_id: im.uid,
					to_id: im.roomId
				};

				$.post(postUrl, postdata, function (res) {
					if (res.status == 1) {
						var f = res.data.from;
						var t = res.data.to;
						var url = "../../pages/wallet/sendTxEmb.html?fromtype=2&id=" + f['id'] + "&name=" + f['name'] + "&pubkey=" + f.pubkey + "&type=" + f.type + "&tokens=" + f.tokens + "&isdefault=1&user_id=" + im.uid + "&to=" + t.address;
						mui.openWindow({
							url: url,
							id: 'pages/chat/transfer_accounts',
							extras: {
								roomId: im.roomId
							}
						});
					} else {
						mui.alert(res.msg);
					}
				});
			//} else {
			//	mui.alert("功能未开通");
			//}
		});
	
	});

	window.addEventListener('PAY_ZHUANZHANG_SUCC', function (event) {
		var detailid = event.detail.detailid;
		var tradeid = event.detail.tradeid;
		var fromtype = event.detail.fromtype;
		var remark = event.detail.remark;
		var money = event.detail.money;
	
		im.sendMsg({
			sender: 'self',
			type: 'remove',
			content: detailid,
			extras:{
				tradeid: tradeid,
				remark: remark,
				money: money
			}
		});
		im.playsendSound('zz');
	});

	window.addEventListener('RECV_ZHUANZHANG_SUCC', function (event) {
		im.sendMsg({
			sender: 'self',
			type: 'recvzhuanzhang',
			content: im.user_name
		});
		im.playsendSound('zz');
	});
}(mui, im, document));